import { parseDataFile } from './migrate';
import { powerSaveBlocker } from 'electron';

const primitiveType = ['string', 'boolean', 'number'];

let powerSaveBlockerId: number | null = null;
export const setPowerSaveBlocker = (enabled: boolean) => {
  let isEnabled = powerSaveBlockerId != null && powerSaveBlocker.isStarted(powerSaveBlockerId);
  if (enabled) {
    if (isEnabled) return;
    powerSaveBlockerId = powerSaveBlocker.start('prevent-app-suspension');
  } else {
    if (!isEnabled) return;
    powerSaveBlocker.stop(powerSaveBlockerId!);
    powerSaveBlockerId = null;
  }
};
